<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>任务管理</title>
<meta name="decorator" content="default" />
<link rel="stylesheet" href="../../../../static/bootstrap/2.3.1/css_default/bootstrap.min.css" type="text/css"></link>
<!-- <style type="text/css"> -->
<!-- .table{ -->
<!--     table-layout: fixed; -->
<!-- } -->
<!-- </style> -->
<script type="text/javascript">
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}

	function checkImportPath() {
		return true;
	}

        
	function selectAll(){  
	    if ($("#SelectAll").attr("checked")) {  
	        $(":checkbox").attr("checked", true);  
	    } else {  
	        $(":checkbox").attr("checked", false);  
	    }  
	}  
	
	//子复选框的事件  
	function setSelectAll(){  
	    //当没有选中某个子复选框时，SelectAll取消选中  
	    if (!$("#subcheck").checked) {  
	        $("#SelectAll").attr("checked", false);  
	    }  
	    var chsub = $("input[type='checkbox'][id='subcheck']").length; //获取subcheck的个数  
	    var checkedsub = $("input[type='checkbox'][id='subcheck']:checked").length; //获取选中的subcheck的个数  
	    
	    if (checkedsub == chsub) {  
	        $("#SelectAll").attr("checked", true);  
	    } 
    }
    function jQstringify( obj ) {
		var arr = [];
		$.each( obj, function( key, val ) {
		var next = key + ": ";
		next += $.isPlainObject( val ) ? printObj( val ) : val;
		arr.push( next );
		});
		return "{ " + arr.join( ", " ) + " }";
	}
	//批量删除
	function deletesel(){
		var chk_value =[];    
		$("input[type='checkbox'][id='subcheck']:checked").each(function(){    
			 chk_value.push($(this).val());    
			});  	
		if (chk_value.length >0){
			//alert("${ctx}/cms/taskOperation/deletesel?ids=" + JSON.stringify(chk_value));
			$.get("${ctx}/cms/taskOperation/deletesel?ids=" + JSON.stringify(chk_value), function(data){
					alert(JSON.stringify(data)); 
					$("#searchForm").submit();
			});
		}else{
			alert("请选择数据！");
		}
	}
	//指派
	function assign(){
		var chk_value =[];    
		$("input[type='checkbox'][id='subcheck']:checked").each(function(){    
		 chk_value.push($(this).val());    
		});  	
		var userid = $("#user1Name").val();
		if (userid=="")
		{
			alert("请选择用户！");
			return;
		}
		if (chk_value.length >0){
			$.get("${ctx}/cms/taskOperation/assign?ids=" + JSON.stringify(chk_value)+"&userid="+$("#user1Name").val(), function(data){
					alert(JSON.stringify(data)); 
					$("#searchForm").submit();
			});
		}else{
			alert("请选择数据！");
		}
	}
    
    //合并功能
    function merge(){
//     	alert("11111111111111");
		var chk_value =[];    
		$("input[type='checkbox'][id='subcheck']:checked").each(function(){    
		 chk_value.push($(this).val());    
		});    
		//alert(chk_value.length<=1 ?"你还没有选择任何内容！":chk_value.length);  
		
		var userid = $("#user1Name").val();
		if (userid=="")
		{
			alert("请选择用户！");
			return;
		}
		if (chk_value.length >1){
			//
			//alert("${ctx}/cms/taskOperation/megre?ids=" + JSON.stringify(chk_value)); 
			$.get("${ctx}/cms/taskOperation/megre?ids=" + JSON.stringify(chk_value)+"&userid="+$("#user1Name").val(), function(data){
					alert(JSON.stringify(data)); 
					$("#searchForm").submit();  
// 				if (data == "true"){
// 					alert(JSON.stringify(data)); 
// 					alert("成功"); 
// 				}else{
// 					alert("提交失败");  
// 				}
			});
		}else{
			alert("请选择两行或多行数据！");
		}

	}
	
	
//             (function ($) {
//                 var running = false;
//                 $('a.likeable').on('click', function (e) {
//                     e.preventDefault();
//                     if (running) return;
//                     running = true;
//                     var like = $(this);
//                     $.post("http://tool.lu/like.html", {id: like.data('id')}, function (data) {
//                         if (data.status) {
//                             like.find('i.icon').removeClass('like').addClass('liked');
//                             like.find('var').text(data.text);
//                         }
//                         running = false;
//                     }, 'json');
//                 });
//             })(jQuery);
	
// 		var uphone = $scope.user.tel;  
//         var pwd = $scope.user.pwd;  
//         var arrays = new Array();//定义一个数组  
//         arrays[0] = uphone;//将获取的值赋进去  
//         arrays[1] = pwd;  
//         $http(  
//                 {  
//                     method : 'get',  
//                     url : '../memquery?params=' + JSON.stringify(arrays)//使用json传递  
//                             + '&opId=10001&cityId=6101'  
//                 }).success(function(data) {  
//             alert(JSON.stringify(data));  
//             alert("成功");  
//         }).error(function() {  
//             alert("提交失败");  
//         }); 
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/cms/taskOperation/">任务列表</a>
		</li>
		<%-- <li><a
			href="<c:url value='${fns:getAdminPath()}/cms/taskOperation/form?id=${taskOperation.id}&keyfield=${taskOperation.keyfield}'></c:url>">任务添加</a>
		</li> --%>
	</ul>
	<form:form id="searchForm" modelAttribute="taskOperation"
		action="${ctx}/cms/taskOperation/list" method="post"
		class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		<input id="pageSize" name="pageSize" type="hidden"
			value="${page.pageSize}" />

		<label>产品：</label>
		<form:input path="productid" htmlEscape="false" maxlength="50"
			class="input-small" />&nbsp;
		<label>子任务：</label>
		<form:input path="dptask" htmlEscape="false" maxlength="50"
			class="input-small" />&nbsp;
			<label>工序：</label>
		<form:input path="opdesc" htmlEscape="false" maxlength="50"
			class="input-small" />&nbsp;
			<label>任务计划日期范围：&nbsp;</label>
		<input name="beginPdate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${taskOperation.beginPdate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> - 
				<input name="endPdate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${taskOperation.endPdate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>&nbsp;&nbsp;
		<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" />&nbsp;&nbsp;
		<a class="btn btn-primary" href="javascript:merge();"
			onclick="return confirmx('确认要合并选中数据吗？', this.href)">合并</a>
		<a class="btn btn-primary" href="javascript:assign();"
			onclick="return confirmx('确认指派吗？', this.href)">指派执行账户</a>
			<sys:treeselect2 id="user1" name="user.loginName" value="${testData.user.loginName}" labelName="user.loginName" labelValue="${testData.user.loginName}"
					title="用户" url="/sys/office/treeData?type=3" cssClass="input-small" allowClear="true" notAllowSelectParent="true"/>&nbsp;&nbsp;
		<a class="btn btn-primary" href="javascript:deletesel();" onclick="return confirmx('确认删除吗？', this.href)">删除</a>
	</form:form>
	<sys:message content="${message}" />
	
	<table id="contentTable" style="width: 3600px"
		class="table table-striped table-bordered table-hover table-condensed">
		
		<thead>
			<tr >
				<th><!-- 全选<br> -->
				<p><input type="checkbox" id="SelectAll"
					onclick="selectAll()" /></p>
				</th>
				<th >关键字段</th>
				<th>产品id</th>
				<th>产品名称</th>
				<th>工序</th>
				<th>子任务</th>
				<th>部门</th>
				<th>任务计划日期</th>
				<th>产值a</th>
				<th>产值b</th>
				<th>产值c</th>
				<th>产值d</th>
				<th>产值e</th>
				<th>产值f</th>
				<th>产值g</th>
				<th>产值h</th>
				<th>类型</th>
				<th>完工</th>
				<th>标志工序</th>
				<th>工段完成</th>
				<th>检验</th>
				<th>合格</th>
				<th>开工</th>
				<th>用户id</th>
				<th>岗位id</th>
				<th>合并id</th>
				<th>HALO订单号</th>
				<th>PO号</th>
				<th>订单特性要求</th>
				<th>产品编码</th>
				<th>小订单号</th>
				<th>英文描述</th>
				<th>生产备注</th>
				<th>工序ID</th>
				<th>部门ID</th>
				<th>SKU</th>
				<th>单位体积</th>
				<th>单位难度系统</th>
				<th>开始时间</th>
				<th>产品组</th>
				<th>HALO CODE</th>
				<th>套件标识号</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="task">
				 <tr >
					<td><input type="checkbox" id="subcheck"
						value="${task.id}" onclick="setSelectAll()"></input>
					</td>	
					<td>${task.keyfield}</td>
					<td>${task.productid}</td>
					<td>${task.productname}</td>
					<td>${task.opdesc}</td>
					<td>${task.dptask}</td>
					<td>${task.dept}</td>
					<td><fmt:formatDate value="${task.pdate}" pattern="yyyy-MM-dd"/></td>
					<td>${task.a}</td>
					<td>${task.b}</td>
					<td>${task.c}</td>
					<td>${task.d}</td>
					<td>${task.e}</td>
					<td>${task.f}</td>
					<td>${task.g}</td>
					<td>${task.h}</td>
					<td>${task.tasktype}</td>
					<td>${task.istaskcomplete}</td>
					<td>${task.istagprocess}</td>
					<td>${task.ispartcomplete}</td>
					<td>${task.isqctask}</td>
					<td>${task.isok}</td>
					<td>${task.isstart}</td>
					<td>${task.userid}</td>
					<td>${task.jobgroupid}</td>
					<td>${task.taskGroupId}</td>
					<td>${task.character01}</td>
					<td>${task.character02}</td>
					<td>${task.character03}</td>
					<td>${task.partnum}</td>
					<td>${task.character04}</td>
					<td>${task.character06}</td>
					<td>${task.commenttext}</td>
					<td>${task.opcode}</td>
					<td>${task.jcdept}</td>
					<td>${task.character05}</td>
					<td>${task.number07}</td>
					<td>${task.number13}</td>
					<td>${task.starhour}</td>
					<td>${task.prodcode}</td>
					<td>${task.xpartnum}</td>
					<td>${task.number03}</td>
					<td><%-- <a href="${ctx}/cms/taskOperation/form?id=${task.id}">修改</a> --%>
						<a href="${ctx}/cms/taskOperation/delete?id=${task.id}"
						onclick="return confirmx('确认要删除该任务吗？', this.href)">删除</a>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	
	
	<div class="pagination">${page}</div>
</body>
</html>